package com.zgjl.api.config;

import com.zgjl.api.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@EnableConfigurationProperties(SecurityConfigProperties.class)
@Configuration
public class SecurityAutoConfiguration {

    @Autowired
    public SecurityAutoConfiguration(SecurityConfigProperties properties) {
        // 在Spring启动时初始化静态工具类
        JWTUtil.setJwtSecret(properties.getJwtSecret());
        SM4Util.setSm4Secret(properties.getSm4Secret());
        HmacSM3Util.setTimeWindowMs(properties.getTimeWindowMs());
        HmacUtil.setTimeWindowMs(properties.getTimeWindowMs());
        HttpSecurityRequestTool.setTimeouts(properties.getConnectTimeout(), properties.getReadTimeout(),properties.getPlatformId());
    }

}
